using System;

class PrintNumbersToNDivide7and3
{
	static void Main()
	{
		Console.Write("N=");
		int n = Int32.Parse(Console.ReadLine());
		Console.Write("\n");
		Console.WriteLine("This numbers are not divisible by 3 and 7 at same time");
		for (int num = 1; num <= n; num++)
		{
			if(num % 3 > 0 && num % 7 > 0)
			{
			Console.WriteLine(num);
			}
		}
		Console.WriteLine("This numbers are divisible by 3 and 7 at same time");
		for (int num = 1; num <= n; num++)
		{
			if(num % 3 == 0 && num % 7 == 0)
			{
			Console.WriteLine(num);
			}
		}
	}
}